package org.example.springbootpra1.demos.bean.enums;

public enum DeviceStatus {
    ENABLED(1), // 设备启用
    DISABLED(0); // 设备禁用

    private int code;

    DeviceStatus(int code) {
        this.code = code;
    }

    public int getCode() {
        return code;
    }

    public static DeviceStatus fromCode(int code) {
        for (DeviceStatus status : values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }
}
